package com.xubeizhi.common;

// 统一结果返回类

import lombok.Data;

@Data
public class Result<T> {
    private int code;  // 业务状态码
    private String message; // 提示信息
    private Object data;  // 响应数据

    //快速返回操作成功响应结果(带响应数据)
    public static <E> Result<E> success(E data) {
        return new Result<>(0, "操作成功", data);
    }

    public Result(int code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public static Result error(int code,String message,Object data){
        return new Result(1,message,null);
    }

    public static Result success(int code,String message,Object data){
        return new Result(0,message,data);
    }

    public int getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    public Object getData() {
        return data;
    }
}
